<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qquickitemanimation.cpp -->
  <title>AnchorAnimation QML 类型 | Qt Quick 5.12.3</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.12</a></td><td ><a href="qtquick-index.html">Qt Quick 模块</a></td><td ><a href="qtquick-qmlmodule.html">QML类型</a></td><td >AnchorAnimation QML 类型</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtquick-index.html">Qt 5.12.3 参考指南</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">目录</a></h3>
<ul>
<li class="level1"><a href="#properties">属性</a></li>
<li class="level1"><a href="#details">详细信息</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">AnchorAnimation QML 类型</h1>
<span class="subtitle"></span>
<!-- $$$AnchorAnimation-brief -->
<p>Animates changes in anchor values. <a href="#details">更多...</a></p>
<!-- @@@AnchorAnimation -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> 导入语句：</td><td class="memItemRight bottomAlign"> import QtQuick 2.12</td></tr><tr><td class="memItemLeft rightAlign topAlign">继承自：</td><td class="memItemRight bottomAlign"> <p><a href="qml-qtquick-animation.html">Animation</a></p>
</td></tr></table></div><ul>
<li><a href="qml-qtquick-anchoranimation-members.html">所有成员的列表，包括继承成员</a></li>
</ul>
<a name="properties"></a>
<h2 id="properties">属性</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtquick-anchoranimation.html#duration-prop">duration</a></b></b> : int</li>
<li class="fn"><b><b><a href="qml-qtquick-anchoranimation.html#easing-prop">easing</a></b></b><ul>
<li class="fn"><b><b><a href="qml-qtquick-anchoranimation.html#easing.type-prop">easing.type</a></b></b> : enumeration</li>
<li class="fn"><b><b><a href="qml-qtquick-anchoranimation.html#easing.amplitude-prop">easing.amplitude</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-anchoranimation.html#easing.overshoot-prop">easing.overshoot</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-anchoranimation.html#easing.period-prop">easing.period</a></b></b> : real</li>
</ul>
</li>
<li class="fn"><b><b><a href="qml-qtquick-anchoranimation.html#targets-prop">targets</a></b></b> : list&lt;Item&gt;</li>
</ul>
<!-- $$$AnchorAnimation-description -->
<a name="details"></a>
<h2 id="details">详细信息</h2>
<p><a href="qml-qtquick-anchoranimation.html">AnchorAnimation</a> is used to animate an anchor change.</p>
<p>In the following snippet we animate the addition of a right anchor to a <a href="qml-qtquick-rectangle.html">Rectangle</a>:</p>
<pre class="qml">

  import QtQuick 2.0

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
      <span class="name">id</span>: <span class="name">container</span>
      <span class="name">width</span>: <span class="number">200</span>; <span class="name">height</span>: <span class="number">200</span>

      <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
          <span class="name">id</span>: <span class="name">myRect</span>
          <span class="name">width</span>: <span class="number">100</span>; <span class="name">height</span>: <span class="number">100</span>
          <span class="name">color</span>: <span class="string">&quot;red&quot;</span>
      }

      <span class="name">states</span>: <span class="name">State</span> {
          <span class="name">name</span>: <span class="string">&quot;reanchored&quot;</span>
          <span class="type"><a href="qml-qtquick-anchorchanges.html">AnchorChanges</a></span> { <span class="name">target</span>: <span class="name">myRect</span>; <span class="name">anchors</span>.right: <span class="name">container</span>.<span class="name">right</span> }
      }

      <span class="name">transitions</span>: <span class="name">Transition</span> {
          <span class="comment">// smoothly reanchor myRect and move into new position</span>
          <span class="type"><a href="qml-qtquick-anchoranimation.html">AnchorAnimation</a></span> { <span class="name">duration</span>: <span class="number">1000</span> }
      }

      <span class="name">Component</span>.onCompleted: <span class="name">container</span>.<span class="name">state</span> <span class="operator">=</span> <span class="string">&quot;reanchored&quot;</span>
  }

</pre>
<p>When an <a href="qml-qtquick-anchoranimation.html">AnchorAnimation</a> is used in a <a href="qmlexampletoggleswitch.html#transition">Transition</a>, it will animate any <a href="qml-qtquick-anchorchanges.html">AnchorChanges</a> that have occurred during the state change. This can be overridden by setting a specific target item using the <a href="qml-qtquick-anchorchanges.html#target-prop">AnchorChanges.target</a> property.</p>
<p><b>Note: </b><a href="qml-qtquick-anchoranimation.html">AnchorAnimation</a> can only be used in a <a href="qmlexampletoggleswitch.html#transition">Transition</a> and in conjunction with an AnchorChange. It cannot be used in behaviors and other types of animations.</p><p><b>See also </b><a href="qtquick-statesanimations-animations.html">Animation and Transitions in Qt Quick</a> and <a href="qml-qtquick-anchorchanges.html">AnchorChanges</a>.</p>
<!-- @@@AnchorAnimation -->
<h2>属性文档</h2>
<!-- $$$duration -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="duration-prop">
<td class="tblQmlPropNode"><p>
<a name="duration-prop"></a><span class="name">duration</span> : <span class="type"><a href="../qtqml/qml-int.html">int</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the duration of the animation, in milliseconds.</p>
<p>The default value is 250.</p>
</div></div><!-- @@@duration -->
<br/>
<!-- $$$easing -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="even" id="easing-prop"><th class="centerAlign"><p><a name="easing-prop"></a><b>easing group</b></p></th></tr><tr valign="top" class="odd" id="easing.type-prop"><td class="tblQmlPropNode"><p><a name="easing.type-prop"></a><span class="name">easing.type</span> : <span class="type"><a href="../qtqml/qml-enumeration.html">enumeration</a></span></p></td></tr><tr valign="top" class="odd" id="easing.amplitude-prop"><td class="tblQmlPropNode"><p><a name="easing.amplitude-prop"></a><span class="name">easing.amplitude</span> : <span class="type"><a href="../qtqml/qml-real.html">real</a></span></p></td></tr><tr valign="top" class="odd" id="easing.overshoot-prop"><td class="tblQmlPropNode"><p><a name="easing.overshoot-prop"></a><span class="name">easing.overshoot</span> : <span class="type"><a href="../qtqml/qml-real.html">real</a></span></p></td></tr><tr valign="top" class="odd" id="easing.period-prop"><td class="tblQmlPropNode"><p><a name="easing.period-prop"></a><span class="name">easing.period</span> : <span class="type"><a href="../qtqml/qml-real.html">real</a></span></p></td></tr></table></div></div><div class="qmldoc"><p>Specifies the easing curve used for the animation</p>
<p>To specify an easing curve you need to specify at least the type. For some curves you can also specify amplitude, period and/or overshoot. The default easing curve is Linear.</p>
<pre class="qml">

  <span class="type"><a href="qml-qtquick-anchoranimation.html">AnchorAnimation</a></span> { <span class="name">easing</span>.type: <span class="name">Easing</span>.<span class="name">InOutQuad</span> }

</pre>
<p>See the <a href="qml-qtquick-propertyanimation.html#easing.type-prop">PropertyAnimation::easing.type</a> documentation for information about the different types of easing curves.</p>
</div></div><!-- @@@easing -->
<br/>
<!-- $$$targets -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="targets-prop">
<td class="tblQmlPropNode"><p>
<a name="targets-prop"></a><span class="name">targets</span> : <span class="type"><a href="../qtqml/qml-list.html">list</a></span>&lt;<span class="type"><a href="qml-qtquick-item.html">Item</a></span>&gt;</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The items to reanchor.</p>
<p>If no targets are specified all <a href="qml-qtquick-anchorchanges.html">AnchorChanges</a> will be animated by the <a href="qml-qtquick-anchoranimation.html">AnchorAnimation</a>.</p>
</div></div><!-- @@@targets -->
<br/>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
